using System;
using System.Collections.Generic;
using UnityEngine;

[Serializable]
public class prelayer_class
{
	public bool foldout;

	public bool linked;

	public remarks_class remarks;

	public bool interface_display_layergroup;

	public bool interface_display_layer;

	public bool layers_foldout;

	public bool layers_active;

	public int index;

	public int level;

	public List<layer_class> layer;

	public predescription_class predescription;

	public string layer_text;

	public layer_output_enum layer_output;

	public Rect view_menu_rect;

	public Rect menuRect;

	public bool view_heightmap_layer;

	public bool view_color_layer;

	public bool view_splat_layer;

	public bool view_tree_layer;

	public bool view_grass_layer;

	public bool view_object_layer;

	public bool view_only_selected;

	public float x;

	public float y;

	public float counter_y;

	public int count_terrain;

	public float break_x_value;

	public area_class prearea;

	public bool area;

	public List<distance_class> objects_placed;

	public prelayer_class(int length, int index2)
	{
		foldout = true;
		linked = true;
		remarks = new remarks_class();
		interface_display_layer = true;
		layers_foldout = true;
		layers_active = true;
		layer = new List<layer_class>();
		predescription = new predescription_class();
		layer_text = "Layer(1):";
		view_heightmap_layer = true;
		view_color_layer = true;
		view_splat_layer = true;
		view_tree_layer = true;
		view_grass_layer = true;
		view_object_layer = true;
		prearea = new area_class();
		objects_placed = new List<distance_class>();
		index = index2;
		if (length > 0)
		{
			for (int i = 0; i < length; i++)
			{
				layer.Add(new layer_class());
				layer[0].output = layer_output_enum.splat;
				predescription.add_layer_index(i, i, 0);
			}
		}
	}

	public void set_prelayer_text()
	{
		layer_text = "Layer Level" + index + "(" + layer.Count + ")";
	}

	public void new_layer(int layer_number, List<filter_class> filter)
	{
		layer[layer_number] = new layer_class();
	}

	public void change_layers_active_from_description(int description_number, bool invert, bool heightmap_output, bool color_output, bool splat_output, bool tree_output, bool grass_output, bool object_output)
	{
		layer_class layer_class = null;
		for (int i = 0; i < predescription.description[description_number].layer_index.Count; i++)
		{
			layer_class = layer[predescription.description[description_number].layer_index[i]];
			if ((layer_class.output == layer_output_enum.heightmap && heightmap_output) || (layer_class.output == layer_output_enum.color && color_output) || (layer_class.output == layer_output_enum.splat && splat_output) || (layer_class.output == layer_output_enum.tree && tree_output) || (layer_class.output == layer_output_enum.grass && grass_output) || (layer_class.output == layer_output_enum.@object && object_output))
			{
				if (!invert)
				{
					layer_class.active = predescription.description[description_number].layers_active;
				}
				else
				{
					layer_class.active = !layer_class.active;
				}
			}
		}
	}

	public void change_layers_foldout_from_description(int description_number, bool invert, bool heightmap_output, bool color_output, bool splat_output, bool tree_output, bool grass_output, bool object_output)
	{
		layer_class layer_class = null;
		for (int i = 0; i < predescription.description[description_number].layer_index.Count; i++)
		{
			layer_class = layer[predescription.description[description_number].layer_index[i]];
			if ((layer_class.output == layer_output_enum.heightmap && heightmap_output) || (layer_class.output == layer_output_enum.color && color_output) || (layer_class.output == layer_output_enum.splat && splat_output) || (layer_class.output == layer_output_enum.tree && tree_output) || (layer_class.output == layer_output_enum.grass && grass_output) || (layer_class.output == layer_output_enum.@object && object_output))
			{
				layer_class = layer[predescription.description[description_number].layer_index[i]];
				if (!invert)
				{
					layer_class.foldout = predescription.description[description_number].layers_foldout;
				}
				else
				{
					layer_class.foldout = !layer_class.foldout;
				}
			}
		}
	}

	public void change_layers_active(bool invert)
	{
		for (int i = 0; i < layer.Count; i++)
		{
			if (!invert)
			{
				layer[i].active = layers_active;
			}
			else
			{
				layer[i].active = !layer[i].active;
			}
		}
	}

	public void change_foldout_layers(bool invert)
	{
		for (int i = 0; i < layer.Count; i++)
		{
			if (!invert)
			{
				layer[i].foldout = layers_foldout;
			}
			else
			{
				layer[i].foldout = !layer[i].foldout;
			}
		}
	}

	public void swap_layer2(int number1, int number2)
	{
		layer_class value = layer[number1];
		layer[number1] = layer[number2];
		layer[number2] = value;
		if (!(layer[number1].color_layer[0] >= 1.5f))
		{
			layer[number1].color_layer = layer[number1].color_layer + new Color(1f, 1f, 1f, 1f);
		}
		if (!(layer[number2].color_layer[0] >= 1.5f))
		{
			layer[number2].color_layer = layer[number2].color_layer + new Color(1f, 1f, 1f, 1f);
		}
	}
}
